import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import Detail from './views/Detail.vue'
import Test from './views/Test.vue'

Vue.use(Router)

 const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      meta: {
        pathTitle: '',
        keepAlive: true,
        isBack: false
      }
    }, {
      path: '/detail',
      name: 'detail',
      component: Detail
    }, {
      path: '/test',
      name: 'test',
      component: Test
    }
  ]
})
export default router

router.beforeEach((to, from, next) => {
  if(from.name == 'home'){
      if(to.name == 'detail'){
          from.meta.keepAlive = true;
      }else{
          from.meta.keepAlive = false;
      }
  }
  next()
})
